package model.dao;

import java.sql.PreparedStatement;
import model.Dao;
import model.entity.Veiculo;


public class VeiculoDAO extends Dao {

  public static Veiculo insert_veiculo(Veiculo v) {
    try {
      PreparedStatement pstmt = getConnection().prepareStatement(
        "Insert Into veiculo(placa, ano_fabricacao, ano_modelo, cor, marca, modelo, proprietario) "
        + "Values(?, ?, ?, ?, ?, ?, ?)");
      pstmt.setObject(1, v.getPlaca());
      pstmt.setObject(2, v.getAnofabricacao());
      pstmt.setObject(3, v.getAnomodelo());
      pstmt.setObject(4, v.getCor());
      pstmt.setObject(5, v.getMarca());
      pstmt.setObject(6, v.getModelo());
      pstmt.setObject(7, v.getProprietario().getNome());
      pstmt.executeUpdate();
      //

      pstmt.close();
    } catch (Exception e) {

    }
    return v;
  }

  public static Veiculo update(Veiculo v) {
    try {
      PreparedStatement pstmt = getConnection().prepareStatement(
        "Update Notas Set Nota = ?, Semestre = ?, Materia = ? "
        + "Where id =?");
      pstmt.setObject(1, v.getPlaca());
      pstmt.setObject(2, v.getAnofabricacao());
      pstmt.setObject(3, v.getAnomodelo());
      pstmt.setObject(4, v.getCor());
      pstmt.setObject(5, v.getMarca());
      pstmt.setObject(6, v.getModelo());
      pstmt.setObject(7, v.getProprietario().getNome());
      pstmt.executeUpdate();
      //
     
      pstmt.close();
    } catch (Exception e) {

    }
 return v;
  }
}